package com.exam.serviceimpl;

import com.exam.entity.ClassScore;
import com.exam.mapper.ClassScoreRepository;
import com.exam.service.ClassScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class ClassScoreServiceImpl implements ClassScoreService {

    @Autowired
    private ClassScoreRepository classScoreRepository;

    @Override
    public Page<ClassScore> getScoresByClassId(Integer classId, Pageable pageable) {
        return classScoreRepository.findByClassId(classId, pageable);
    }

    @Override
    public Page<ClassScore> getScoresByClassIdAndCourse(Integer classId, String courseName, Pageable pageable) {
        return classScoreRepository.findByClassIdAndCourseName(classId, courseName, pageable);
    }

    @Override
    public ClassScore saveOrUpdateClassScore(ClassScore classScore) {
        return classScoreRepository.save(classScore);
    }

    @Override
    public void deleteClassScoreById(Integer classScoreId) {
        classScoreRepository.deleteById(classScoreId);
    }
}